package com.blog.admin.controller;

import com.blog.admin.service.CommentService;
import com.blog.common.core.web.domain.AjaxResult;
import com.blog.common.domain.dto.CommentDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;

/**
 * <p>
 * 评论后台控制器
 * </p>
 *
 * @author Valerie
 * @date 2023/4/12
 **/
@RestController
@Api("评论后台管理")
public class CommentBackController {

    @Resource
    private CommentService commentService;

    /**
     * 查询评论
     *
     * @param commentDto 条件
     * @return {@link AjaxResult}
     */
    @GetMapping("/comment/list")
    @ApiOperation("删除评论")
    public AjaxResult listComments(CommentDto commentDto){
        return AjaxResult.success(commentService.listComments(commentDto));
    }


    /**
     * 审核评论
     *
     * @param id id
     * @param isReview 状态
     * @return {@link AjaxResult}
     */
    @GetMapping("/comment/audit")
    @ApiOperation("审核评论")
    public AjaxResult auditComment(@RequestParam("id") Serializable id, @RequestParam("status") Boolean isReview){
        commentService.auditComment(id, isReview);
        return AjaxResult.success();
    }

    /**
     * 删除评论
     *
     * @param commentIds id
     * @return {@link AjaxResult}
     */
    @DeleteMapping("/comment")
    @ApiOperation("删除评论")
    public AjaxResult removeComment(@RequestParam("commentIds") String commentIds){
        commentService.removeComment(commentIds);
        return AjaxResult.success();
    }

}
